﻿using Infrastructure.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Domain
{
    /// <summary>
    /// 仓储基本接口
    /// 要求所有具体仓储接口派生于此接口
    /// <remarks></remarks>
    /// </summary>
    /// <typeparam name="T">实体类型</typeparam>
    public interface IRepository<T>: IUnitOfWork where T : EntityBase
    {
       
        /// <summary>
        /// 清除上下文本地缓存
        /// 如果上下文对象生命周期很长久
        /// 可能需要手动调用些方法来清除上下文的缓存
        /// </summary>
        void ClearLocalCache();

        /// <summary>
        /// 通过存储过程删除数据
        /// </summary>
        /// <param name="id">实体id</param>
        /// <param name="spName">存储过程名字，默认值是：proc_实体名_del</param>
        /// <returns>操作后的结果</returns>
        string DeleteBySP(Guid id, string spName = null);

        /// <summary>
        /// 通过存储过程批量删除数据
        /// </summary>
        /// <param name="ids">id的字符串逗号分隔（即js 数组toString()的数据）</param>
        /// <param name="delList">把成功删除实体添加到实例化的集合delList中</param>
        /// <param name="spName">存储过程名称</param>
        /// <returns></returns>
        string DeleteBySP(string ids, ref List<T> delList, string spName = null);

        /// <summary>
        /// 通过存储过程删除时间范围内数据
        /// </summary>
        /// <param name="starttime">开始时间</param>
        /// <param name="endtime">结止时间</param>
        /// <param name="spname">存储结构名称</param>
        /// <param name="message">执行结果</param>
        /// <returns>返回需要删除文件列表</returns>
        List<string> DeleteAllBySP(int systemid, DateTime starttime, DateTime endtime, string spname, out string message);
    }
}
